﻿Imports Microsoft.VisualBasic
Imports System.Data
Imports System.Data.SqlClient

Public Class clsDA_WhatCookToday
    Private _SqlCnn As SqlConnection
    Private _connectionString As String
    Public Sub New()
        ' Read the attributes for this provider
        If System.Configuration.ConfigurationManager.ConnectionStrings("ConString").ConnectionString <> "" Then
            _connectionString = System.Configuration.ConfigurationManager.ConnectionStrings("ConString").ConnectionString
        End If
        _SqlCnn = New SqlConnection(_connectionString)
        Try
            _SqlCnn.Open()
        Catch ex As Exception
            _SqlCnn = Nothing
        End Try
    End Sub
    Public Sub Destructor()
        If Not _SqlCnn Is Nothing Then
            If _SqlCnn.State <> Data.ConnectionState.Closed Then _SqlCnn.Close()
            _SqlCnn.Dispose()
            _SqlCnn = Nothing
        End If
    End Sub
    'Select FormulaType, Formula
    Public Function Select_FormulaType_Formula() As DataSet
        Dim dt_all As New DataSet
        Dim sqlAdp As New SqlClient.SqlDataAdapter
        Dim sqlTrans As SqlClient.SqlTransaction = _SqlCnn.BeginTransaction()
        sqlAdp.SelectCommand = New SqlClient.SqlCommand
        With sqlAdp.SelectCommand
            Try
                .Connection = _SqlCnn
                .Transaction = sqlTrans
                .CommandText = "uspSelectFormulaType"
                .CommandType = CommandType.StoredProcedure
                sqlAdp.Fill(dt_all)
                sqlTrans.Commit()
            Catch Exp As SqlClient.SqlException
                sqlTrans.Rollback()
            Finally
                .Parameters.Clear()
            End Try
        End With
        If Not sqlAdp Is Nothing Then
            If Not sqlAdp.SelectCommand Is Nothing Then
                sqlAdp.SelectCommand.Dispose()
            End If
            sqlAdp.Dispose()
        End If
        Return dt_all
    End Function

End Class
